package com.fastloan.common.model;

import com.alibaba.fastjson.JSON;

public class CheckResult {

    private String checkMsg;

    private boolean checkResult;

    private Object data;

    private Integer code;

    public CheckResult(String checkMsg) {
        this.checkMsg = checkMsg;
        this.checkResult = false;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public <T> T getData(Class<T> clazz) {
        if (data == null){
            return null;
        }
        return (T) data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public CheckResult() {
        this.checkResult = true;
    }

    public static CheckResult success(){
        return new CheckResult();
    }

    public static CheckResult success(Object object){
        CheckResult checkResult = new CheckResult();
        checkResult.setData(object);
        return checkResult;
    }

    public static CheckResult fail(String msg ,Object object){
        CheckResult checkResult = new CheckResult(msg);
        checkResult.setData(object);
        return checkResult;
    }

    public static CheckResult fail(String msg){
        return new CheckResult(msg);
    }

    public static CheckResult fail(String msg,Integer code){
        CheckResult checkResult = new CheckResult(msg);
        checkResult.setCode(code);
        return checkResult;
    }

    public String getCheckMsg() {
            return checkMsg;

        }

    public CheckResult setCheckMsg(String checkMsg) {
        this.checkMsg = checkMsg;
        return this;
    }

    public boolean isCheckResult() {
        return checkResult;
    }

    public CheckResult setCheckResult(boolean checkResult) {
        this.checkResult = checkResult;
        return this;
    }

}